<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="box">
        <p>子元素</p>
        <p>子元素</p>
        <div>
            <p>孙子元素</p>
        </div>
    </div>
    <div>
        <ul>
            <li>1</li>
            <li>2</li>
            <li>3</li>
        </ul>
    </div>
<script src="js/jquery-3.6.0.min.js"></script>
<script>
$(function(){
    //$('#box').children('p').css('background','red');
    //$('#box').find('p').css('background','red');
    //$('li').parent().css('background','red');
    $('li').parents('body').css('background','red');
})
</script>
</body>
</html>